package es.unileon.is.finalproyect.auxiliar;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Streams {

	public static byte[] inputStreamToByteArray(InputStream is){
		try{
			byte b[] = new byte[1024];
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			while(is.read(b)>0){
				baos.write(b);
			}
			return baos.toByteArray();
		} catch (IOException e){
			throw new RuntimeException(e.getMessage());
		}
	}
	
	public static InputStream byteArrayToInputStream(byte[] b){
		return new ByteArrayInputStream(b);
	}
}
